﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using NNanomsg.Protocols;

namespace WPFNanoMsgServer
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        PublishSocket serversocket = new PublishSocket();
        string address;

        public MainWindow()
        {
            InitializeComponent();
        }

        private void button_Click(object sender, RoutedEventArgs e)
        {
            //获取参数并启动
            serversocket.Bind(textBox_address.Text);
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            string topic = textBox_topic.Text;
            string content = textBox_content.Text;
            string message = topic + "|" + content;
            byte[] b = Encoding.UTF8.GetBytes(message);
            serversocket.Send(b);
            if(textBlock_log.Text.Count()>5000)
            {
                textBlock_log.Text = "";
            }
            textBlock_log.Text ="publish msg:"+ message + "\n" + textBlock_log.Text;
        }
    }
}
